import request from '../utils/request'
import crypto from '../utils/secret'

export function loginByUsername (username, password) {
  const data = {
    type: 'normal',
    identifier: username,
    credential: crypto.encrypt(password)
  }
  /* console.log(password);
   const enPwd = crypto.encrypt(password);
   console.log(enPwd);
   const decPwd = crypto.decrypt(enPwd);
   console.log(decPwd);
   */
  console.log(data)
  return request({
    url: '/auth/signIn',
    method: 'post',
    data: data
  })
}

export function logout () {
  return request({
    url: '/auth/logout',
    method: 'post'
  })
}

export function getUserInfo (token) {
  return request({
    url: '/user/info',
    method: 'get',
    params: { token }
  })
}
